<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"theeyaesakura.gitee.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="没有创意，只好旧活新整(搬移老工程)">
<meta property="og:type" content="article">
<meta property="og:title" content="art-pi上手体验">
<meta property="og:url" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/index.html">
<meta property="og:site_name" content="SOME">
<meta property="og:description" content="没有创意，只好旧活新整(搬移老工程)">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/IMG_20201208_210434.jpg">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/IMG_20201208_210452.jpg">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/Screenshot_20201208_211732_com.huawei.browser.jpg">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208231853982.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208231924281.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208232039783.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208232045905.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208232151162.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208232231108.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/20201208232302783.png">
<meta property="og:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/IMG_20201208_225947.jpg">
<meta property="article:published_time" content="2020-12-08T16:12:37.000Z">
<meta property="article:modified_time" content="2020-12-08T16:23:41.643Z">
<meta property="article:author" content="茶沉小团月">
<meta property="article:tag" content="RT-Thread">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://theeyaesakura.gitee.io/2020/12/09/art-pi/IMG_20201208_210434.jpg">

<link rel="canonical" href="https://theeyaesakura.gitee.io/2020/12/09/art-pi/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>art-pi上手体验 | SOME</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="SOME" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">SOME</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">学习记录</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://theeyaesakura.gitee.io/2020/12/09/art-pi/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/2.jpg">
      <meta itemprop="name" content="茶沉小团月">
      <meta itemprop="description" content="Just For Fun">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="SOME">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
		  art-pi上手体验
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-12-09 00:12:37 / 修改时间：00:23:41" itemprop="dateCreated datePublished" datetime="2020-12-09T00:12:37+08:00">2020-12-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%AD%A6%E4%B9%A0/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.3k</span>
            </span>
            <div class="post-description">没有创意，只好旧活新整(搬移老工程)</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="一、先来张照片"><a href="#一、先来张照片" class="headerlink" title="一、先来张照片"></a>一、先来张照片</h3><p><img src="/2020/12/09/art-pi/IMG_20201208_210434.jpg" alt="IMG_20201208_210434"><br><img src="/2020/12/09/art-pi/IMG_20201208_210452.jpg" alt="IMG_20201208_210452"></p>
<p>art-pi的做工我看着是真的舒服。很符合RT-Thread官网的那句话”小而美”了。</p>
<h3 id="二、出厂程序体验"><a href="#二、出厂程序体验" class="headerlink" title="二、出厂程序体验"></a>二、出厂程序体验</h3><p>出厂例程是通过蓝牙对开发板进行配网，内置一个web服务器，配网成功后能够通过网页显示开发板的基本信息，并对开发板的板载LED进行简单的控制。</p>
<h4 id="蓝牙配网流程直接看GitHub的文档即可"><a href="#蓝牙配网流程直接看GitHub的文档即可" class="headerlink" title="蓝牙配网流程直接看GitHub的文档即可"></a>蓝牙配网流程直接看GitHub的文档即可</h4><p><img src="/2020/12/09/art-pi/Screenshot_20201208_211732_com.huawei.browser.jpg" alt="Screenshot_20201208_211732_com.huawei.browser"></p>
<p>配网成功以后，这个网页是真的骚，可以查看内存、norflash、SD等信息。</p>
<h3 id="三、驱动I2C的OLED屏幕"><a href="#三、驱动I2C的OLED屏幕" class="headerlink" title="三、驱动I2C的OLED屏幕"></a>三、驱动I2C的OLED屏幕</h3><p>其实拿到art-pi之后，并没有什么好的创意来发挥H7的实力。RT-Thread最近半年多也一直在学习，也有几个比赛我也上了rtt，但是学艺不精，比赛只取得了一个勉强看得过去的成绩。</p>
<p>没有新的整活，于是就只好旧活新整，把原来F103上的东西搬到ART-Pi上。</p>
<h5 id="物料："><a href="#物料：" class="headerlink" title="物料："></a>物料：</h5><p>OLED * 1</p>
<p>ART-Pi * 1</p>
<h5 id="平台："><a href="#平台：" class="headerlink" title="平台："></a>平台：</h5><p>RT-Thread Studio</p>
<h5 id="主要代码"><a href="#主要代码" class="headerlink" title="主要代码"></a>主要代码</h5><p>本来是打算用原来的方式开发的，即：用RT-Thread Nano。但是体验过了rtt软件的方便，就不想自己手写外设驱动了，抱着试一下的心态，搜索了一下OLED的软件包，还真的有。果断用起来。这个原来是用在arduino上的库已经被大佬移植的好好的了，直接用轮子就好了；而且还提供了example，一些重复代码直接复制粘贴就可以了。</p>
<p><img src="/2020/12/09/art-pi/20201208231853982.png" alt="在这里插入图片描述"></p>
<p><img src="/2020/12/09/art-pi/20201208231924281.png" alt="在这里插入图片描述"></p>
<p>如图配置即可</p>
<h6 id="在cv过程中遇到的小坑"><a href="#在cv过程中遇到的小坑" class="headerlink" title="在cv过程中遇到的小坑"></a>在cv过程中遇到的小坑</h6><p>仔细观察ART-Pi的板子，就会发现上边没有标注引脚名称……最后找到了<strong>ART-Pi扩展引脚说明.pdf</strong>这个文档</p>
<p><img src="/2020/12/09/art-pi/20201208232039783.png" alt="在这里插入图片描述"></p>
<p><img src="/2020/12/09/art-pi/20201208232045905.png" alt="在这里插入图片描述"><br>在这里插入图片描述<br>从上图可以看出PH11、PH12分别是I2C的SCL、SDA。随后，回到rtt-studio打开<code>drv_gpio.c</code>找到PH11、PH12对应的引脚号(如下图所示)。但是这个方法略显麻烦。<br><img src="/2020/12/09/art-pi/20201208232151162.png" alt="在这里插入图片描述"></p>
<p>由于这是stm32的mcu，所以我们可以直接通过这个<code>GET_PIN(port,pin)</code>这个宏来获取引脚编号，这个宏在<code>drv_common.h</code>中定义：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)</span></span><br></pre></td></tr></table></figure>

<p>所以代码有两种写法：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">define</span> OLED_I2C_PIN_SCL                    123   <span class="comment">// PH11</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> OLED_I2C_PIN_SDA                    124   <span class="comment">// PH12</span></span></span><br></pre></td></tr></table></figure>

<p>或者</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">define</span> OLED_I2C_PIN_SCL                    GET_PIN(H,11)   <span class="comment">// PH11</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> OLED_I2C_PIN_SDA                    GET_PIN(H,12)   <span class="comment">// PH12</span></span></span><br></pre></td></tr></table></figure>

<p>值得注意的是使用第二种写法时，一定要添加头文件 <code>#include “drv_common.h”</code>，不然会报错。</p>
<p>在OLED显示这方面，参考了其他大佬的代码。但是他们的代码都是跑在死循环里边的，一旦使用了就不能用Finsh控制台了，就很烦。我稍微改了一下，加了一个线程并且导出了MSH命令：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;rthw.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;rtthread.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;rtdevice.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;U8g2lib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;drv_common.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;drv_soft_i2c.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> THREAD_PRIORITY         25</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> THREAD_STACK_SIZE       1024</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> THREAD_TIMESLICE        5</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">rt_thread_t</span> tid1 = RT_NULL;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> OLED_I2C_PIN_SCL                    GET_PIN(H,11)   <span class="comment">// PH11</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> OLED_I2C_PIN_SDA                    GET_PIN(H,12)   <span class="comment">// PH12</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> U8G2_SSD1306_128X64_NONAME_F_SW_I2C <span class="title">u8g2</span><span class="params">(U8G2_R0,\</span></span></span><br><span class="line"><span class="function"><span class="params">                                         <span class="comment">/* clock=*/</span> OLED_I2C_PIN_SCL,\</span></span></span><br><span class="line"><span class="function"><span class="params">                                         <span class="comment">/* data=*/</span> OLED_I2C_PIN_SDA,\</span></span></span><br><span class="line"><span class="function"><span class="params">                                         <span class="comment">/* reset=*/</span> U8X8_PIN_NONE)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">oled_display</span><span class="params">(<span class="keyword">void</span> *param)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    u8g2.begin();</span><br><span class="line">    u8g2.clearBuffer();</span><br><span class="line"></span><br><span class="line">    u8g2.setFont(u8g2_font_logisoso32_tf);</span><br><span class="line">    u8g2.setCursor(<span class="number">48</span>+<span class="number">3</span>, <span class="number">42</span>);</span><br><span class="line">    u8g2.print(<span class="string">&quot;Hi~&quot;</span>);     <span class="comment">// requires enableUTF8Print()</span></span><br><span class="line"></span><br><span class="line">    u8g2.setFont(u8g2_font_6x13_tr);            <span class="comment">// choose a suitable font</span></span><br><span class="line">    u8g2.drawStr(<span class="number">30</span>, <span class="number">60</span>, <span class="string">&quot;By Sakura&quot;</span>);   <span class="comment">// write something to the internal memory</span></span><br><span class="line">    u8g2.sendBuffer();</span><br><span class="line"></span><br><span class="line">    rt_thread_mdelay(<span class="number">2000</span>);</span><br><span class="line">    <span class="keyword">char</span> mstr[<span class="number">3</span>];</span><br><span class="line">    <span class="keyword">char</span> hstr[<span class="number">3</span>];</span><br><span class="line">    <span class="keyword">time_t</span> now;</span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">tm</span> *<span class="title">p</span>;</span></span><br><span class="line">    <span class="keyword">int</span> min = <span class="number">0</span>, hour = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        now = time(RT_NULL);</span><br><span class="line">        p=gmtime((<span class="keyword">const</span> <span class="keyword">time_t</span>*) &amp;now);</span><br><span class="line">        hour = p-&gt;tm_hour;</span><br><span class="line">        min = p-&gt;tm_min;</span><br><span class="line">        <span class="built_in">sprintf</span>(mstr, <span class="string">&quot;%02d&quot;</span>, min);</span><br><span class="line">        <span class="built_in">sprintf</span>(hstr, <span class="string">&quot;%02d&quot;</span>, hour);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        u8g2.firstPage();</span><br><span class="line">        <span class="keyword">do</span> &#123;</span><br><span class="line">             u8g2.setFont(u8g2_font_logisoso42_tn);</span><br><span class="line">             u8g2.drawStr(<span class="number">0</span>,<span class="number">63</span>,hstr);</span><br><span class="line">             u8g2.drawStr(<span class="number">50</span>,<span class="number">63</span>,<span class="string">&quot;:&quot;</span>);</span><br><span class="line">             u8g2.drawStr(<span class="number">67</span>,<span class="number">63</span>,mstr);</span><br><span class="line">           &#125;</span><br><span class="line">        <span class="keyword">while</span> ( u8g2.nextPage() );</span><br><span class="line"></span><br><span class="line">        rt_thread_mdelay(<span class="number">50</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">thread_sample</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/* 创建线程 1，名称是 thread1，入口是 thread1_entry*/</span></span><br><span class="line">    tid1 = rt_thread_create(<span class="string">&quot;thread1&quot;</span>,</span><br><span class="line">                            oled_display, RT_NULL,</span><br><span class="line">                            THREAD_STACK_SIZE,</span><br><span class="line">                            THREAD_PRIORITY, THREAD_TIMESLICE);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* 如果获得线程控制块，启动这个线程 */</span></span><br><span class="line">    <span class="keyword">if</span> (tid1 != RT_NULL)</span><br><span class="line">        rt_thread_startup(tid1);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* 导出到 msh 命令列表中 */</span></span><br><span class="line">MSH_CMD_EXPORT(thread_sample, thread sample);</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="效果"><a href="#效果" class="headerlink" title="效果"></a>效果</h5><p>先联网。使用的是板载WiFi模块，使用命令 <code>wifi join [SSID] [PASSWORD]</code>连网即可。</p>
<p><img src="/2020/12/09/art-pi/20201208232231108.png" alt="在这里插入图片描述"></p>
<p>导出的msh命令列表里边还有个同步网络时间的命令 <code>date</code></p>
<p><img src="/2020/12/09/art-pi/20201208232302783.png" alt="在这里插入图片描述"></p>
<p>最后输入 <code>thread_sample</code> ：</p>
<p><img src="/2020/12/09/art-pi/IMG_20201208_225947.jpg" alt="IMG_20201208_225947"></p>
<h5 id="遗留问题"><a href="#遗留问题" class="headerlink" title="遗留问题"></a>遗留问题</h5><ol>
<li><p>这个功能就是一个简单的网络助手。但是从上边的演示过程中，可以看到，需要手动输入命令才能跑起来。这样很不智能啊，但是板载的WiFi模块(AP6212)我在工程中找了半天也没看到关于它的代码在哪儿。有空仔细研究研究，怎么在系统初始化时就连上网络、同步网络时间</p>
</li>
<li><p>PH11、PH12的引脚应该是属于硬件iic，但是我配置的是软件iic。这其中会不会有不同目前还没有深究，下回试试其他引脚来模拟iic</p>
</li>
</ol>

    </div>

    
    
    
	<div>
		
			<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------THE END-------------</div>
    
</div>

		
	</div>
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/images/wechat_channel.jpg">
            <span class="icon">
              <i class="fab fa-weixin"></i>
            </span>

            <span class="label">WeChat</span>
          </a>
        </div>

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/RT-Thread/" rel="tag"># RT-Thread</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/12/08/%E4%B8%80%E4%BA%9B%E5%AD%A6%E4%B9%A0%E8%BF%87%E7%A8%8B%E4%B8%AD%E9%81%87%E5%88%B0%E7%9A%84%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" rel="prev" title="一些学习过程中遇到的常用命令">
      <i class="fa fa-chevron-left"></i> 一些学习过程中遇到的常用命令
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/12/11/wsl2%E7%BC%96%E8%AF%91Linux-Kernel/" rel="next" title="wsl2编译Linux Kernel">
      wsl2编译Linux Kernel <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%85%88%E6%9D%A5%E5%BC%A0%E7%85%A7%E7%89%87"><span class="nav-number">1.</span> <span class="nav-text">一、先来张照片</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%87%BA%E5%8E%82%E7%A8%8B%E5%BA%8F%E4%BD%93%E9%AA%8C"><span class="nav-number">2.</span> <span class="nav-text">二、出厂程序体验</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%93%9D%E7%89%99%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B%E7%9B%B4%E6%8E%A5%E7%9C%8BGitHub%E7%9A%84%E6%96%87%E6%A1%A3%E5%8D%B3%E5%8F%AF"><span class="nav-number">2.1.</span> <span class="nav-text">蓝牙配网流程直接看GitHub的文档即可</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E9%A9%B1%E5%8A%A8I2C%E7%9A%84OLED%E5%B1%8F%E5%B9%95"><span class="nav-number">3.</span> <span class="nav-text">三、驱动I2C的OLED屏幕</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E7%89%A9%E6%96%99%EF%BC%9A"><span class="nav-number">3.0.1.</span> <span class="nav-text">物料：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%B9%B3%E5%8F%B0%EF%BC%9A"><span class="nav-number">3.0.2.</span> <span class="nav-text">平台：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%B8%BB%E8%A6%81%E4%BB%A3%E7%A0%81"><span class="nav-number">3.0.3.</span> <span class="nav-text">主要代码</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#%E5%9C%A8cv%E8%BF%87%E7%A8%8B%E4%B8%AD%E9%81%87%E5%88%B0%E7%9A%84%E5%B0%8F%E5%9D%91"><span class="nav-number">3.0.3.1.</span> <span class="nav-text">在cv过程中遇到的小坑</span></a></li></ol></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%95%88%E6%9E%9C"><span class="nav-number">3.0.4.</span> <span class="nav-text">效果</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E9%81%97%E7%95%99%E9%97%AE%E9%A2%98"><span class="nav-number">3.0.5.</span> <span class="nav-text">遗留问题</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="茶沉小团月"
      src="/images/2.jpg">
  <p class="site-author-name" itemprop="name">茶沉小团月</p>
  <div class="site-description" itemprop="description">Just For Fun</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">8</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/JaminLeeMJ" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;JaminLeeMJ" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:1097282916@qq.com" title="E-Mail → mailto:1097282916@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://yoursite.com/" title="http:&#x2F;&#x2F;yoursite.com" rel="noopener" target="_blank">Title</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>
    <footer class="footer">
      <div class="footer-inner">
        

        
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">茶沉小团月</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">19k</span>
</div>
<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共7.7k字</span>
</div>


<div class="powered-by">
<i class="fa fa-user-md"></i><span id="busuanzi_container_site_uv">
  本站访客数:<span id="busuanzi_value_site_uv"></span>
</span>
</div>


        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>















  

  

</body>
</html>
<script type="text/javascript" src="/js/clicklove.js"></script>
<!-- 动态背景 -->
<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>

